package com.jjb.www.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.hjq.shape.view.ShapeImageView;
import com.hjq.shape.view.ShapeTextView;
import com.jjb.www.R;
import com.jjb.www.app.AppAdapter;
import com.jjb.www.http.api.HistoryListApi;
import com.jjb.www.http.glide.GlideApp;

/**
 *    author : Android CRG
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2018/11/05
 */
public final class HistoryListAdapter extends AppAdapter<HistoryListApi.Bean> {

    public HistoryListAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private ShapeTextView mTvName;
        private ShapeTextView mTvIntroduce;
        private ShapeImageView mImgType;



        private ViewHolder() {
            super(R.layout.item_history_list);
            mTvName = findViewById(R.id.tv_name);
            mTvIntroduce = findViewById(R.id.tv_introduce);
            mImgType = findViewById(R.id.img_type);
        }

        @Override
        public void onBindView(int position) {
            HistoryListApi.Bean bean = getItem(position);
            mTvName.setText(bean.getSentry_name());
            mTvIntroduce.setText(bean.getTeach_name());
            if (bean.getPlan_type()==1){
                mImgType.setImageResource(R.mipmap.icon_list_jj);
            }else {
                mImgType.setImageResource(R.mipmap.icon_list_gq);
            }
        }
    }
}